package cn.itheima.service.company.impl;

import cn.itheima.dao.company.CompanyDao;
import cn.itheima.domain.Company;
import cn.itheima.domain.PageBean;
import cn.itheima.service.company.CompanyService;
import cn.itheima.domain.Company;
import cn.itheima.service.company.CompanyService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CompanyServiceImpl implements CompanyService {
    @Autowired
    private CompanyDao companyDao;
    //全查
    public List<Company> findAll() {
        return companyDao.findAll();
    }

    //添加
    public void edit(Company company) {
        companyDao.edit(company);
    }

    //修改往返
    public Company toUpdate(String id) {
        Company company=companyDao.toUpdate(id);
        return company;
    }

    //修改企业信息
    public void Update(Company company) {
        companyDao.Update(company);
    }

    //删除企业
    public void delete(String id) {
        companyDao.delete(id);
    }

    //分页查找
    public  PageInfo findAll2(int pageNumber, int pageSize) {
        PageHelper.startPage(pageNumber,pageSize);
        List<Company> list = companyDao.findAll();
        PageInfo pageInfo = new PageInfo(list);
        return pageInfo;
    }
}
